<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>卡片库存统计</title>

<script type="text/javascript" src="../script/common.js"></script>
<script type="text/javascript" language="javascript" src="../script/common_stat.js"></script>
<script language="javascript" src="../script/core/mootools.js" type="text/javascript"></script>

<script type="text/javascript">
	var crosstab = new Crosstab();
	var statForm;
	var pivot;
	function load(){
		Eui.showNavigation();
		setPages(["queryView","newPivot"]);
		
		statForm = $("statForm");
		
		Common.initDict(statForm.cardStatus,CardStore.getStoreStatus(),"全 部");
		
		
	 	//初始化卡片状态
	 	var storeStatus = Common.getSubsetItems(CardStoreStatus.CATEGORY, [CardStoreStatus.MANUFACTURE, CardStoreStatus.STORE, CardStoreStatus.ONPASSAGE, CardStoreStatus.LOST, CardStoreStatus.DAMAGED]);
	 	Common.initDict("storeStatus",storeStatus,"全 部");
		
		statForm.orgId.value = Common.cOrg().id;
		$("statForm").orgName.value = Common.cOrg().name
		newPivot()
	}
	
	function selCardType(){			
		var v = openDialogFrame("/basic/card_type_list.html?",'请选择卡片类型',464,700)
		if (v){
			statForm.cardTypeName.value = v[1]; 	 
		}
	}
	
	function selCard(){			
		var v = openDialogFrame("/store/sel_white_list.html?",'请选择卡片规格',464,700)
		if (v){
			statForm.cardSpecName.value = v.name; 	 
		}
	}
	function newPivot(){
		var sql = "card_stat";
		var crossconf = {};
		crossconf.measures = {"count":"总数"}
		crossconf.dimensions = {"cardType":{name:"卡片类型",option:{"baseCardType":"基本卡片类型","name":"名称"}},"cardSpec":{name:"卡片规格",option:{factory:"厂商",name:"名称"}},"storeStatus":"库存状态","status":"卡片状态"}
		crossconf.defaultMeasure = {count:true};
		crossconf.defaultVertical = {storeStatus:true};
		crossconf.defaultHorizon = {cardType:{baseCardType:true,name:true},status:true,"cardSpec":{factory:true,name:true}};
		pivot = new Pivot('newPivot',sql,null,{initPivotHead:initPivotHead});
		pivot.initConf(crossconf);
		pivot.setPivotHead('pivotTitle','卡片库存统计');
	}
	function initPivotHead(div){
		var title = '<table width="100%" border="0" cellspacing="0" cellpadding="5" style="width:600">'
				  + '<tr><td align="center" class="reportTitle" height="50" colspan="3" id="#DIVID#_pivotTitle"></td></tr>'
				  + '<tr><td width="30%">统 计 人：<span id="#DIVID#_statOper"></span></td><td width="35%">统计机构：<span id="#DIVID#_statOrg"></span></td><td>统计时间：<span id="#DIVID#_statTime"></span></td></tr>'
				  + '<tr><td>机构名称：<span id="#DIVID#_orgName"></span></td><td>库存状态：<span id="#DIVID#_storeStatus"></span></td><td>卡片状态：<span id="#DIVID#_cardStatus"></span></td></tr>'
				  + '<tr><td>卡片类型：<span id="#DIVID#_cardTypeName"></span></td><td>卡片规格：<span id="#DIVID#_cardSpecName"></span></td></tr></table>';
		$(div+'_pivot_head').innerHTML = title.replace(/#DIVID#/g,div);
	}
	function doQuery(){
		if(!checkForm(statForm))return;
			
		pivot.param = Common.getValues(statForm);
		pivot.setPivotHead('statTime',Format.today(true));
		pivot.setPivotHead('statOper',Common.cOperator().name);
		pivot.setPivotHead('statOrg',Common.cOrg().name);
		pivot.setPivotHead('statOrg',Common.cOrg().name);
		pivot.setPivotHead('orgName',pivot.param.orgName);
		pivot.setPivotHead('storeStatus',pivot.param.storeStatus?Common.getText("cardstore_status",pivot.param.storeStatus):"全部");
		pivot.setPivotHead('cardStatus',pivot.param.cardStatus?Common.getText("card_status",pivot.param.cardStatus):"全部");
		pivot.setPivotHead('cardSpecName',pivot.param.cardSpecName?pivot.param.cardSpecName:"全部");
		pivot.setPivotHead('cardTypeName',pivot.param.cardTypeName?pivot.param.cardTypeName:"全部");
	
		pivot.refresh();
			
		switchPage('newPivot');
	}
	
	function resetStatForm(){
		//statForm.reset();
		//statForm.orgId.value = Common.cOrg().id;
		switchPage('queryView');
	}
	//选择机构方法
	function setOrg(sorg) {
		statForm.orgName.value = sorg.name;
	    $("orgId").value = sorg.id;
	}
</script>
</head>

<body onload="load()">
	<div class="nav"><div id="nav">&nbsp;</div></div>
	<div id="queryView" class="form">
		<div class="formTitle">卡片库存统计：查询条件</div>
		<form id="statForm" name="statForm">
			<input type="hidden" name="orgId"/>
			<table width="100%" cellspacing="0" cellpadding="4" class="col3">
				<tr>
					<td><label>卡片类型</label> <input type="text" name="cardTypeName" ><a class="orga" title="请选择卡片类型" href="javascript:void(0)" onclick="selCardType()">&nbsp;&nbsp;</a></td>
					<td><label>卡片状态</label> <select name="cardStatus"></select></td>
					<td><label>机构名称</label> <input type="text" name="orgName" class="readonly"> <a class="orga" href="#" onclick="SystemMgnt.selOrg(setOrg);">&nbsp;&nbsp;</a></td>
				</tr>
				<tr>
					<td><label>卡片规格</label> <input type="text" name="cardSpecName" ><a class="orga" title="选择卡片规格" href="javascript:void(0)" onclick="selCard()">&nbsp;&nbsp;</a></td>
					<td><label>库存状态</label> <select name="storeStatus"></select></td>
					<td id="stat_btn"><button type="button" onclick="doQuery()">查 询</button></td>
				</tr>
			</table>
		</form>
	</div>
	<!-- Flash 报表-->
	<div id="newPivot" style="display:none;"></div>
	
</body>

</html>
